<?php
/**
 * CreateTime: 2023/2/23 15:04
 */

namespace App\Models\MeLawCase;

use App\Consts\BaseConsts\BaseConsts;
use App\Consts\TableConsts\TableConsts;
use App\Models\BaseModelV2;
use App\Scopes\MediationStaffScope;

class MeLawCasePhoneModel extends BaseModelV2
{
    protected $table = TableConsts::ME_LAW_CASE_PHONE;

    protected $primaryKey = 'law_case_phone_id';

    protected $fillable = [
        'law_case_phone_id',
        'phone_number',
        'phone_status',
        'is_law_case_main_phone',
        'created_time',
        'updated_time',
        'status'
    ];

    /**
     * 注册全局作用域
     */
    protected static function booted()
    {
        // static::addGlobalScope(new MediationStaffScope());
    }

    public function getDataByPhone($phone){
        return $this->where('phone_number',$phone)->first();
    }

    public function getByIds(array $phones,$select = ["*"])
    {
        return $this->select($select)->whereIn('law_case_phone_id',$phones)->get()->toArray();
    }

    /**
     * 状态
     * @param $value
     * @return string
     */
    public function getPhoneStatusStrAttribute($value): string
    {
        if($value == 1){
            return "近期未响应";
        }
        return "近期响应";
    }


}